<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>发布件数管理</title>
	<%@ include file="/view/common/tags.jsp"%>
</head>
<body>
<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box">
				<div class="box-body">
					<div class="panel panel-default">
						<div class="panel-body" style="padding-bottom:5px;">
							<form class="form-horizontal" action="" method="post" id="dataForm">
								<div class="searchMenu">
									<div>
										<label>游戏名称：</label>
										<sk:select cssClass="form-control select" id="gameId" name="wm[GAME_ID]" value="${page.wm.GAME_ID}" requiredInit="true" ajaxURL="${userInfoV1}/baseGame/gameSelect?wm[DEL_FLAG]=1" onchange="changeGameQuerySmall(this.value)">
											<option value="">请选择</option>
										</sk:select>
									</div>
									<div>
										<label>商品小类：</label>
										<sk:select cssClass="form-control select" id="goodsSmallId" name="wm[GOODS_SMALL_ID]" value="${page.wm.GOODS_SMALL_ID}">
											<option id="smallTypeEle" value="">请选择</option>
										</sk:select>
									</div>
									<div style="float:right;">
										<button type="button"  class="btn btn-primary btn-sm"  onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
										<sk:button type="button"  rightKey="20170816153238"  _class="btn btn-success btn-sm"  onclick="add()"><span class='glyphicon glyphicon-plus'></span>添&nbsp;加</sk:button>
									</div>
								</div>
							</form>
						</div>
					</div>
					<table class="table table-hover table-condensed table-bordered table-striped" id="dataTable" >
						<thead>
						<tr>
							<th data-field="index" data-align="center" data-formatter="indexFormatter" data-sortable="false">序号</th>
							<th data-field="publishPackageName" data-align="center" data-sortable="true">套餐名称</th>
							<th data-field="gameName" data-align="center" data-sortable="true">游戏名称</th>
							<th data-field="goodsSmallName" data-align="center" data-sortable="true">商品小类名称</th>
							<th data-field="sumPublishNum" data-align="center" data-sortable="true">总发单数</th>
							<th data-field="dayUpdateLimit" data-align="center" data-sortable="true">每日更新次数</th>
							<th data-field="perOrderNum" data-align="center" data-sortable="true">每单件数</th>
							<th data-field="publishDateLimit" data-align="center" data-sortable="true">发布有效期</th>
							<th data-field="deleteButton" data-align="center" data-formatter="buttonFormatter" data-sortable="false">操作</th>
						</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
	</div>
</section>
<%@ include file="/view/common/footer.jsp"%>
</body>
<script>
    // 提示信息
    var msgg='<%=request.getAttribute("msg")%>';
    if (msgg && msgg!=null && msgg!='null') {
        layer.msg(msgg);
    }

    function buttonFormatter(value, row, index) {
        var caozuo1 = "<button id='btn_edit' type='button' onclick='_update("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>修 改</button>";
        //var caozuo2 = "<button id='btn_edit' type='button' onclick='deletePublishNum("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-remove'></span>&nbsp;删&nbsp;除&nbsp;</button>";
        return caozuo1;
    }

    // 加载table 数据
    $(function(){
        $("#dataTable").bootstrapTable({
            url: "${tradeV1}/tradeBasePackagePublishNumDetail/getPublishNumConfigList",
            method:"get",
            contentType: "application/x-www-form-urlencoded",
            pagination:true,
            sidePagination:"server",
            queryParams: function(params) {
                return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));
            }
        });
    })

    var tableIndex = 0;
    // 弹出添加的窗口
    function add(){
        tableIndex = layer.open({
            type: 2,
            title: "添加发布件数配置",
            closeBtn: 1,
            shadeClose: true,
            area: ['600px', '300px'],
            content: '${sysManagerV1}/basePublishNum/toAdd?rowId=0',
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }
    // 弹出添加的窗口      修改功能
    function _update(rowId){
        tableIndex = layer.open({
            type: 2,
            title: "修改发布件数配置",
            closeBtn: 1,
            shadeClose: true,
            area: ['600px', '300px'],
            content: '${sysManagerV1}/basePublishNum/toAdd?rowId='+rowId,
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }
    <%--//删除--%>
    <%--function deleteGameEquipManage(rowId, openFlag){--%>
        <%--layer.confirm("您确认【删除】?", {btn: ['确认', '取消']},--%>
            <%--function(){--%>
                <%--$.ajax({--%>
                    <%--url: "${userInfoV1}/tradeBasePackagePublishNumDetail/delete",--%>
                    <%--type: "post",--%>
                    <%--cache: false,--%>
                    <%--data: {rowId:rowId, token: sessionStorage.getItem("token")},--%>
                    <%--dataType:"json",--%>
                    <%--async:false,--%>
                    <%--success: function(data) {--%>
                        <%--if (data == 1) {--%>
                            <%--layer.msg("删除成功", {icon: 1});--%>
                            <%--findData();--%>
                        <%--} else if(data == "-2"){--%>
                            <%--window.location.href=JSCTX;--%>
                        <%--} else {--%>
                            <%--layer.msg(data, {icon: 5});--%>
                        <%--}--%>
                    <%--}--%>
                <%--});--%>
            <%--});--%>
    <%--}--%>
    //查询
    function findData(){
        $("#dataTable").bootstrapTable("refresh",{} );
    }

    /*bootstrap table点击行事件*/
    $(function(){
        $("body").on("click","table>tbody>tr",function(){
            $(this).css("background","#e1ecf1").siblings().css("background","");
        });
    });

    //下拉列表显示(根据游戏查商品小类)
    function changeGameQuerySmall(gameId) {
        $("#smallTypeEle").siblings().remove();
        if (!CheckUtil.isNotNull(gameId+"")) {
            return false;
        }
        $.ajax({
            type: "post",
            url: "${userInfoV1}/gameGoodsType/smallTypeSelect",
            data:{"wm[GAME_ID]":gameId,"token":sessionStorage.getItem("token")},
            dataType:"json",
            async:false,
            success: function(data) {
                if (data.length<=0) {
                    return;
                }
                var _html = "";
                for (var i=0; i<data.length; i++) {
                    _html += "<option value= '"+data[i].value+"'>"+data[i].label+"</option>";
                }
                $("#smallTypeEle").siblings().remove();
                $("#smallTypeEle").after(_html);
            }
        });
    }
</script>
</html>